<p>When the execution is not explicitly terminated at the end of a switch case, it continues to execute the statements of the following case. While
this is sometimes intentional, it often is a mistake which leads to unexpected behavior.</p>
<h2>Noncompliant Code Example</h2>
<pre>
switch (myVariable) {
  case 1:
    foo();
    break;
  case 2:  // Both 'doSomething()' and 'doSomethingElse()' will be executed. Is it on purpose ?
    doSomething();
  default:
    doSomethingElse();
    break;
}
</pre>
<h2>Compliant Solution</h2>
<pre>
switch (myVariable) {
  case 1:
    foo();
    break;
  case 2:
    doSomething();
    break;
  default:
    doSomethingElse();
    break;
}
</pre>
<h2>Exceptions</h2>
<p>This rule is relaxed in the following cases:</p>
<pre>
switch (myVariable) {
  case 0:                                // Empty case used to specify the same behavior for a group of cases.
  case 1:
    doSomething();
    break;
  case 2:                                // Use of return statement
    return;
  case 3:                                // Use of throw statement
    throw new IllegalStateException();
  case 4:                                // Use of continue statement
    continue;
  default:                               // For the last case, use of break statement is optional
    doSomethingElse();
}
</pre>
<h2>See</h2>
<ul>
  <li> <a href="http://cwe.mitre.org/data/definitions/484.html">MITRE, CWE-484</a> - Omitted Break Statement in Switch </li>
  <li> <a href="https://wiki.sei.cmu.edu/confluence/x/ldYxBQ">CERT, MSC17-C.</a> - Finish every set of statements associated with a case label with a
  break statement </li>
  <li> <a href="https://wiki.sei.cmu.edu/confluence/x/1DdGBQ">CERT, MSC52-J.</a> - Finish every set of statements associated with a case label with a
  break statement </li>
</ul>

